import CryptoJS from 'crypto-js'

// import {getToken } from  '@/utils/auth'

const KEY = CryptoJS.enc.Hex.parse('!49E)B@of(]_}E{R')
const AES_Encrypt = (plaintext) => {
  return CryptoJS.AES.encrypt(plaintext, KEY, {
    mode: CryptoJS.mode.ECB,
    padding: CryptoJS.pad.Pkcs7
  }).toString();
}

const AES_Decrypt = (jsonStr)=>{
  return CryptoJS.AES.decrypt(jsonStr, KEY, {
    mode:CryptoJS.mode.ECB,
    padding:CryptoJS.pad.Pkcs7
  }).toString();
}

const HmacSHA512 = (str)=>{
  return CryptoJS.HmacSHA512(str, KEY).toString(CryptoJS.enc.Base64);
}

export {AES_Decrypt, AES_Encrypt, HmacSHA512};
